import { applyMiddleware, legacy_createStore as createStore } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk, { ThunkAction } from 'redux-thunk';
import { ArticleAction } from './actions/article';
import { ChannelAction } from './actions/channel';
import { TodoAction } from './actions/todos';
import reducers from './reducers';
const store = createStore(reducers, composeWithDevTools(applyMiddleware(thunk)))

// typeof可以获取某个数据的类型
// ReturnType是一个泛型工具类型，可以获取一个函数类型的返回值类型
export type RootState = ReturnType<typeof store.getState>

// 联合所有thunkAction类型
// ThunkAction类型使用
export type RootAction = TodoAction | ChannelAction | ArticleAction
export type RootThunkAction = ThunkAction<void, RootState, unknown, RootAction>

export default store


